
var do_App = sm("do_App");
var do_Page = sm("do_Page");
var nf = sm("do_Notification");
var openHelper = require("helper/open");
var bizzType = require("helper/bizzType");
var userUtil = require("helper/user");
var http = require("helper/http");
var pubUrl = require("url/pub");
var qqHttp = require("helper/http");
var orderHelper = require("helper/order");
var dialog = sm("do_Dialog");

var activityUrl = require("url/activity");
var signHttp = activityUrl.url.sign.create;

var rootview = ui("$");
var btnALayout = ui("btnALayout");
var labelSign=ui("labelSign");
var aLayoutSign=ui("aLayoutSign");

var bizzId;
var bizzType;
var beCommentedId = null; //被回复的评论ID
var beCommentedName = null;//被回复的用户名
var shareTitle="",shareContent="",shareImage="",shareId,shareType;

var isSign=false,status,showStatus,activityId;
//初始化
do_Page.on("initSign",function(data) {
	activityId=data.activityId;
	bizzId=activityId;
	bizzType=data.bizzType;
	isSign = data.isSign;
	status=data.status;
	showStatus=data.showStatus;
	shareTitle=data.shareTitle;
	shareContent=data.shareContent;
	if(null!=data.shareImage){
		shareImage=data.shareImage;
	}
	shareType=data.shareType;
	shareId=data.shareId;
	if(status==2){
		aLayoutSign.bgColor="FE7E0AFF";
		if(isSign){
			labelSign.text = "已报名";
		}else{
			labelSign.text = "报名";
		}
	}else{
		labelSign.text=showStatus;
		aLayoutSign.bgColor="C0C0C0FF";
	}
});
//报名
aLayoutSign.on("touch", "", 5000, function(data) {
	if (!isSign&&status==2) {
		nf.confirm("您确定要报名吗？", "报名", "确定", "取消", function(data, e) {
			if(data == 1){
				addSign();
			}
		})
	}
});
function addSign() {
	var data1 = {
			title : "备注",
			hint : "输入备注内容"
		}
		dialog.open("source://view/reuse/popInput/pop_input.ui", data1, function(data, e) {
			var params = {
					"activityId" : activityId,
					"remark" : data,
				};
				qqHttp.post(signHttp, params, function(data) {
					nf.toast("报名成功");
					isSign = true;
					labelSign.text = "已报名";
					do_Page.fire("activity_sign_refash");
					if(null!=data.orderNo&&''!=data.orderNo){
						orderHelper.toPay(data.orderNo);
					}
				})
		});
}
/*分享*/
var footShare = ui("footShare");
footShare.on("touch", "", 300, function() {
	do_Page.fire("onShare",{showView:"true",shareTitle:shareTitle,shareContent:shareContent,shareId:shareId,shareType:shareType,shareImage:shareImage});
});

/*评论*/
var footComment = ui("footComment");
footComment.on("touch", "", 300, function() {
	var datas = {"bizzId":bizzId,"bizzType":bizzType,"beCommentedId":null};
	do_Page.fire("bottomShow",datas);
});
